import logging
import formatters.glog

"""Configures logging to use the google log format."""

def setLogLevel(level):
  """Sets the log level.

  Args:
    level: logging.WARNING, etc.
  """
  logger = logging.getLogger()
  logger.setLevel(level)

def init():
  logging._acquireLock()
  logger = logging.getLogger()

  setLogLevel(logging.WARNING)
  stream_handler = logging.StreamHandler()
  stream_handler.setFormatter(formatters.glog.GlogFormatter())
  stream_handler.setLevel(logging.DEBUG)
  logger.addHandler(stream_handler)
  logging._releaseLock()

  return logger
